package com.foxmail.aroundme.youtubedemo.fmgIntoRcyView;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.foxmail.aroundme.youtubedemo.R;
import com.foxmail.aroundme.youtubedemo.listview.ListViewAdapter;
import com.foxmail.aroundme.youtubedemo.recyclerview.DividerItemDecoration;
import com.foxmail.aroundme.youtubedemo.recyclerview.RecyclerViewAdapter;
import com.foxmail.aroundme.youtubedemo.recyclerview.RecyclerViewAty;
import com.foxmail.aroundme.youtubedemo.utils.RandomId;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by gzl on 2016/10/25.
 */

public class FrgmemtIntoListView extends Fragment {
    private List<String> list = new ArrayList<String>();
    private RecyclerView recyclerView;
    private RecyclerViewAdapter adapter;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Random random = new Random();
        for(int i = 0 ; i < 100; i ++){
            list.add(RandomId.args[random.nextInt(100)]);
        }
        View view = inflater.inflate(R.layout.into_rcyview, container, false);
        recyclerView = (RecyclerView)view.findViewById(R.id.recy);
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),
                DividerItemDecoration.VERTICAL_LIST));
        adapter = new RecyclerViewAdapter(getActivity(), list, getFragmentManager());
        recyclerView.setAdapter(adapter);

        return view;
    }
}
